# DarkCube X-8 WelcomeWizard Connector

import sqlite3 as database
import os
import sys
import time
import logwriter

class wizard_version:
    def __init__(self):
        return 1.0

class welcome:
    def __init__(self):
        log = logwriter.writer('wizard.py')
        log.status('WelcomeWizard started')
        log.status('Initializing Settings writer')
        #set home path
        if not os.environ.has_key('HOME'):
            userdirectory = os.environ['USERPROFILE']
        else:
            userdirectory = os.environ['HOME']
        log.status('Home Directory set to "'+userdirectory+'"')
        log.status('Checking Database file')
        try:
            open(userdirectory+'\\dc_data.db3')
            log.status('Database fle found, Unlinking . . .')
            os.remove(userdirectory+'\\dc_data.db3')
        except:
            log.notice('Database file not found, starting input procedure')
        #start connection
        dbconnect = database.connect(userdirectory+'\\dc_data.db3')
        log.status('Database connected')
        dbcursor = dbconnect.cursor()
        log.status('Creating Settings Matrix')
        """
        try:
            dbcursor.execute('SELECT * FROM settings')
            log.status('Retrieving data from Settings Table')
            for ele in dbcursor:
                log.status('Name:'+str(ele[0])+',Value: '+str(ele[1]))
        except:
            log.error('Settings Matrix not found, Unlinking old data and closing')
            dbconnect.close()
            os.remove(userdirectory+'\\dc_data.db3')
            sys.exit()
        """
        log.status('WelcomeWizard processes successfully')
                    
if __name__=='__main__':
    print ' WelcomeWizard cannot run individually '
